package com.shitou.util;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.StringReader;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;

import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Element;
import com.itextpdf.text.html.simpleparser.HTMLWorker;
import com.itextpdf.text.html.simpleparser.StyleSheet;
import com.itextpdf.text.pdf.PdfWriter;
import com.shitou.pojo.Project;
public class ReportPdfUtil {
 
    /** The StyleSheet. */
    protected StyleSheet styles = null;
    /** Extra properties. */
    protected HashMap<String,Object> providers = null;
 
 
    /**
     * Creates a list with movies in HTML and PDF simultaneously.
     * @param html a path to the resulting HTML file
     * @param pdf a path to the resulting PDF file
     * @throws SQLException
     * @throws IOException
     * @throws DocumentException
     */
    public void createHtmlAndPdf(String html, String pdf, String realPath,List<Project> projectList)
        throws SQLException, IOException, DocumentException {
        // Create a database connection
        // Create a stream to produce HTML
        PrintStream out = new PrintStream(new FileOutputStream(html));
        
        out.println("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
        out.println("<head>");
        out.println("<meta http-equiv=\"Content-Type\" content=\"text/html;charset=GBK\" />");
        out.println("<title>项目统计</title>");
        out.println("<style type=\"text/css\">");
        out.println("*{margin:0;padding:0;}");
        out.println(".button, #main-content table tfoot td .bulk-actions select, .pagination a.number, form input.text-input, form textarea, form .wysiwyg, form select, .dp-popup {");
        out.println("    border-radius: 4px 4px 4px 4px;");
        out.println("}");
        out.println(".content-box, .content-box-header, ul.content-box-tabs li a.current, .shortcut-button, .notification {");
        out.println("    border-radius: 6px 6px 6px 6px;");
        out.println("}");
        out.println(".content-box-header {");
        out.println("    border-bottom-left-radius: 0;");
        out.println("    border-bottom-right-radius: 0;");
        out.println("}");
        out.println(".closed-box .content-box-header {");
        out.println("    border-bottom-left-radius: 6px;");
        out.println("    border-bottom-right-radius: 6px;");
        out.println("}");
        out.println("ul.content-box-tabs li a.current {");
        out.println("    border-bottom-left-radius: 0;");
        out.println("    border-bottom-right-radius: 0;");
        out.println("}");
        out.println(".shortcut-button span {");
        out.println("    border-radius: 7px 7px 7px 7px;");
        out.println("}");
        out.println("div.wysiwyg ul.panel li a {");
        out.println("    opacity: 0.6;");
        out.println("}");
        out.println("div.wysiwyg ul.panel li a:hover, div.wysiwyg ul.panel li a.active {");
        out.println("    opacity: 0.99;");
        out.println("}");
        out.println("html {"); 
        out.println("font-size: 100%;"); 
        out.println("height: 100%;"); 
        out.println("margin-bottom: 1px;"); 
        out.println("}");
        out.println("a {");
        out.println("color: #57A000;");
        out.println("text-decoration: none;");
        out.println("}");
        out.println("a:hover {");
        out.println("color: #000000;");
        out.println("}");

        out.println("blockquote {");
        out.println("background: url(\""+realPath+"images/bg_blockquote.png\") no-repeat scroll 0 5px transparent;");
        out.println("font-weight: normal;");
        out.println("margin: 0;");
        out.println("padding: 10px 40px 10px 24px;");
        out.println("}");
        out.println("body {"); 
        out.println("font-family: \"微软雅黑\",Arial,Helvetica,sans-serif;"); 
        out.println("color: rgb(85, 85, 85);"); 
        out.println("background: url('"+realPath+"images/bg-body.gif') repeat-y scroll left top rgb(240, 240, 240);"); 
        out.println("font-size: 12px;"); 
        out.println("}");
        out.println("body#login {");
        out.println("background: url(\""+realPath+"images/bg-login.gif\") repeat scroll 0 0 #222222;");
        out.println("color: #FFFFFF;");
        out.println("}");
        out.println("form input.text-input, form select, form textarea, form .wysiwyg {");
        out.println("background: url(\"bg-form-field.gif\") repeat-x scroll left top #FFFFFF;");
        out.println("border: 1px solid #D5D5D5;");
        out.println("color: #333333;");
        out.println("font-size: 13px;");
        out.println("padding: 6px;");
        out.println("}");
        out.println("form label {");
        out.println("display: block;");
        out.println("font-weight: bold;");
        out.println("padding: 0 0 10px;");
        out.println("}");
        out.println("h1, h2, h3, h4, h5, h6 {");
        out.println("color: #222222;");
        out.println("font-family: Helvetica,\"微软雅黑\",Arial,sans-serif;");
        out.println("font-weight: bold;");
        out.println("}");
        out.println("h1 {");
        out.println("color: #FFFFFF;");
        out.println("font-family: Calibri,\"微软雅黑\",Helvetica,Arial,sans-serif;");
        out.println("font-size: 31px;");
        out.println("font-weight: bold;");
        out.println("position: absolute;");
        out.println("top: -1000px;");
        out.println("}");
        out.println("h2 {");
        out.println("font-size: 26px;");
        out.println("padding: 0 0 10px;");
        out.println("}");
        out.println("h3 {");
        out.println("font-size: 17px;");
        out.println("padding: 0 0 10px;");
        out.println("}");
        out.println("img[align=\"absmiddle\"] {");
        out.println("margin-right: 2px;");
        out.println("margin-top: -3px;");
        out.println("}");
        out.println("input[type=\"text\"], input[type=\"password\"] {");
        out.println("background-position: 10px 6px;");
        out.println("border: 1px solid #BBBBBB;");
        out.println("border-radius: 5px 5px 5px 5px;");
        out.println("box-shadow: 0 2px 2px #CCCCCC inset, 0 1px 0 #FFFFFF;");
        out.println("color: #666666;");
        out.println("display: block;");
        out.println("float: left;");
        out.println("height: 20px;");
        out.println("margin: 0 10px;");
        out.println("padding-left: 10px;");
        out.println("width: 90%;");
        out.println("}");
        out.println("ol, ul {");
        out.println("list-style: none outside none;");
        out.println("}");
        out.println("p {");
        out.println("line-height: 1.6em;");
        out.println("padding: 5px 0 10px;");
        out.println("}");
        out.println("ul.actions {");
        out.println("float: right;");
        out.println("height: 24px;");
        out.println("list-style: none outside none;");
        out.println("margin: 3px 10px 0 0;");
        out.println("padding: 0;");
        out.println("}");
        out.println("ul.actions li {");
        out.println("float: left;");
        out.println("line-height: 24px;");
        out.println("margin: 0 0 0 2px;");
        out.println("padding: 0;");
        out.println("}");
        out.println("ul.actions li a.btn {");
        out.println("background-color: #EEEEEE;");
        out.println("border: 1px solid #CCCCCC;");
        out.println("border-radius: 5px 5px 5px 5px;");
        out.println("box-shadow: 0 1px 0 #FFFFFF;");
        out.println("color: #44474F;");
        out.println("display: block;");
        out.println("font-weight: bold;");
        out.println("height: 24px;");
        out.println("padding: 0 10px;");
        out.println("text-decoration: none;");
        out.println("text-shadow: 0 1px 0 #FFFFFF;");
        out.println("}");
        out.println("ul.actions li a.btn:hover {");
        out.println("background-color: #6EB100;");
        out.println("border: 1px solid #A0CF00;");
        out.println("box-shadow: 0 1px 0 #A0CF00;");
        out.println("color: #EEE;");
        out.println("text-shadow: 0 1px 0 #A0CF00;");
        out.println("}");
        out.println("ul.shortcut-buttons-set li {");
        out.println("background: none repeat scroll 0 50% transparent;");
        out.println("float: left;");
        out.println("margin: 0 15px 0 0;");
        out.println("padding: 0 !important;");
        out.println("}");
        out.println("#body-wrapper {");
        out.println("background: url(\""+realPath+"images/bg-radial-gradient.gif\") no-repeat fixed 230px top transparent;");
        out.println("}");
        out.println("#footer {");
        out.println("border-top: 1px solid #CCCCCC;");
        out.println("font-size: 12px;");
        out.println("margin: 40px 0 0;");
        out.println("padding: 20px 0;");
        out.println("}");
        out.println("#login-wrapper {");
        out.println("background: url(\""+realPath+"images/bg-login-top.png\") repeat-x scroll left top transparent;");
        out.println("}");
        out.println("#login-wrapper #login-top {");
        out.println("padding: 140px 0 50px;");
        out.println("text-align: center;");
        out.println("width: 100%;");
        out.println("}");
        out.println("#login-wrapper #login-content {");
        out.println("margin: 0 auto;");
        out.println("text-align: left;");
        out.println("width: 300px;");
        out.println("}");
        out.println("#login-wrapper #login-content .notification {");
        out.println("background-color: #141414;");
        out.println("border: 0 none;");
        out.println("color: #FFFFFF !important;");
        out.println("}");

        out.println("#login-wrapper #login-content p {");
        out.println("padding: 0;");
        out.println("}");
        out.println("#login-wrapper #login-content label {");
        out.println("color: #FFFFFF;");
        out.println("float: left;");
        out.println("font-family: Helvetica,Arial,sans-serif;");
        out.println("font-size: 14px;");
        out.println("font-weight: normal;");
        out.println("padding: 0;");
        out.println("width: 70px;");
        out.println("}");
        out.println("#login-wrapper #login-content input {");
        out.println("background: none repeat scroll 0 0 #FFFFFF;");
        out.println("border: 0 none;");
        out.println("float: right;");
        out.println("margin: 0 0 20px;");
        out.println("width: 200px;");
        out.println("}");
        out.println("#login-wrapper #login-content p .button {");
        out.println("margin-top: 20px;");
        out.println("width: auto;");
        out.println("}");
        out.println("#login-content .notification {");
        out.println("background-position: 10px 11px !important;");
        out.println("background-repeat: no-repeat !important;");
        out.println("border: 1px solid;");
        out.println("font-size: 13px;");
        out.println("margin: 0 0 15px;");
        out.println("padding: 0;");
        out.println("position: relative;");
        out.println("width: 99.8%;");
        out.println("}");
        out.println("#login-wrapper #login-content input.error {");
        out.println("box-shadow: 0 2px 2px #CCCCCC inset, 0 1px 0 #000000;");
        out.println("background: none repeat scroll 0 0 #FFCECE;");
        out.println("border: 1px solid;");
        out.println("border-color: #DF8F8F;");
        out.println("color: #665252;");
        out.println("}");
        out.println("#main-content {");
        out.println("margin: 0 30px 0 260px;");
        out.println("padding: 40px 0 0;");
        out.println("}");
        out.println("#main-content-left {");
        out.println("float: left;");
        out.println("width: 61%;");
        out.println("}");
        out.println("#main-content ul li {");
        out.println("padding: 4px 0 4px 20px;");
        out.println("}");
        out.println("#main-content-left ul, #main-content-left ol {");
        out.println("padding: 10px 0;");
        out.println("}");
        out.println("#main-content-right {");
        out.println("float: right;");
        out.println("padding-left: 3%;");
        out.println("width: 34%;");
        out.println("}");
        out.println("#main-content ul li{");
        out.println("position:relative;");
        out.println("}");
        out.println("#main-content ul li span{");
        out.println("position:absolute;");
        out.println("right:0px;");
        out.println("}");
        out.println("#main-content ul h5{");
        out.println("padding:8px;");
        out.println("padding-left:0px;");
        out.println("}");
        out.println("#main-content ul .start{");
        out.println("background: url('"+realPath+"images/state_open.png') no-repeat  left center;");
        out.println("}");
        out.println("#main-content ul .close{");
        out.println("background: url('"+realPath+"images/state_closed.png') no-repeat scroll left center transparent; padding: 8px 0pt 8px 20px;"); 
        out.println("}");
        out.println("#page-intro {");
        out.println("font-size: 17px;");
        out.println("padding: 0 0 20px;");
        out.println("}");
        out.println("#sidebar {");
        out.println("background: url(\""+realPath+"images/bg-sidebar.gif\") no-repeat scroll left top transparent;");
        out.println("color: #888888;");
        out.println("font-size: 11px;");
        out.println("height: 100%;");
        out.println("left: 0;");
        out.println("position: absolute;");
        out.println("top: 0;");
        out.println("width: 230px;");
        out.println("}");
        out.println("#sidebar a, #sidebar a:active {");
        out.println("color: #CCCCCC;");
        out.println("}");

        out.println("#sidebar #logo {");
        out.println("margin: 40px 0;");
        out.println("}");
        out.println("#sidebar #main-nav {");
        out.println("font-family: Helvetica,\"微软雅黑\",Arial,sans-serif;");
        out.println("margin: 0 0 0 15px;");
        out.println("padding: 0;");
        out.println("width: 206px;");
        out.println("}");
        out.println("#sidebar #main-nav li {");
        out.println("list-style: none outside none;");
        out.println("padding-bottom: 10px;");
        out.println("text-align: right;");
        out.println("}");
        out.println("#sidebar #main-nav li a.nav-top-item {");
        out.println("background: url(\""+realPath+"images/bg-menu-item-green.gif\") no-repeat scroll right center transparent;");
        out.println("color: #FFFFFF;");
        out.println("cursor: pointer;");
        out.println("display: block;");
        out.println("font-size: 14px;");
        out.println("padding: 6px 15px;");
        out.println("text-decoration: none;");
        out.println("}");
        out.println("#sidebar #main-nav li a.current {");
        out.println("background-image: url(\""+realPath+"images/bg-menu-item-current.gif\") !important;");
        out.println("color: #333333;");
        out.println("font-weight: bold;");
        out.println("}");
        out.println("#sidebar #main-nav ul {");
        out.println("font-size: 12px;");
        out.println("margin: 0;");
        out.println("padding: 0;");
        out.println("}");
        out.println("#sidebar #main-nav ul li {");
        out.println("list-style: none outside none;");
        out.println("margin: 0;");
        out.println("padding: 0;");
        out.println("text-align: right;");
        out.println("}");
        out.println("#sidebar #main-nav ul li a {");
        out.println("color: #AAAAAA;");
        out.println("display: block;");
        out.println("font-size: 13px;");
        out.println("line-height: 1.2em;");
        out.println("padding: 8px 15px;");
        out.println("}");
        out.println("#sidebar #main-nav ul li a:hover, #sidebar #main-nav ul li a.current, #sidebar #main-nav ul li a.current:hover {");
        out.println("color: #FFFFFF;");
        out.println("}");
        out.println("#sidebar #main-nav ul li a.current {");
        out.println("background: url(\""+realPath+"images/menu-current-arrow.gif\") no-repeat scroll right center transparent !important;");
        out.println("}");
        out.println("#sidebar #profile-links {");
        out.println("line-height: 1.5em;");
        out.println("padding: 0 15px 20px;");
        out.println("text-align: right;");
        out.println("}");
        out.println("#sidebar #sidebar-title {");
        out.println("margin: 40px 0 40px 15px;");
        out.println("}");
        out.println("#sidebar #sidebar-wrapper {");
        out.println("margin: 0 0 0 9px;");
        out.println("}");
        out.println(".notification {");
        out.println("background-position: 10px 11px !important;");
        out.println("background-repeat: no-repeat !important;");
        out.println("border: 1px solid;");
        out.println("font-size: 13px;");
        out.println("margin: 0 0 15px;");
        out.println("padding: 0;");
        out.println("position: relative;");
        out.println("width: 99.8%;");
        out.println("}");
        out.println(".actions {");
        out.println("list-style: none outside none;");
        out.println("}");
        out.println(".activity-item {");
        out.println("border-bottom: 1px solid #EEEEEE;");
        out.println("color: #666666;");
        out.println("font-size: 13px;");
        out.println("font-weight: bold;");
        out.println("padding: 10px 10px 10px 45px;");
        out.println("position: relative;");
        out.println("}");
        out.println(".activity-item img {");
        out.println("float: right;");
        out.println("}");
        out.println(".activity-item p {");
        out.println("color: #999999;");
        out.println("font-size: 11px;");
        out.println("font-weight: normal;");
        out.println("margin: 5px 0 0;");
        out.println("padding: 0;");
        out.println("}");
        out.println(".activity-item .issues-state-image {");
        out.println("display: inline-block;");
        out.println("float:none;");
        out.println("height: 17px;");
        out.println("width: 50px;");
        out.println("}");
        out.println(".attention {");
        out.println("background: url(\""+realPath+"images/exclamation.png\") no-repeat scroll 10px 11px #FFFBCC;");
        out.println("border-color: #E6DB55;");
        out.println("color: #666452;");
        out.println("}");
        out.println(".box {");
        out.println("width: 600px;");
        out.println("}");
        out.println(".button {");
        out.println("background: url(\""+realPath+"images/bg-button-green.gif\") repeat-x scroll left top #459300 !important;");
        out.println("border: 1px solid #459300 !important;");
        out.println("color: #FFFFFF !important;");
        out.println("cursor: pointer;");
        out.println("display: inline-block;");
        out.println("font-family: Verdana,\"微软雅黑\",Arial,sans-serif;");
        out.println("font-size: 11px !important;");
        out.println("padding: 4px 7px !important;");
        out.println("}");
        out.println(".column-left {");
        out.println("float: left;");
        out.println("width: 48%;");
        out.println("}");
        out.println(".column-right {");
        out.println("float: right;");
        out.println("width: 48%;");
        out.println("}");
        out.println(".content-box {");
        out.println("background: none repeat scroll 0 0 #FFFFFF;");
        out.println("border: 1px solid #CCCCCC;");
        out.println("margin: 0 0 20px;");
        out.println("}");
        out.println(".content-box-header {");
        out.println("background: url(\""+realPath+"images/bg-content-box.gif\") repeat-x scroll left top #E5E5E5;");
        out.println("height: 40px;");
        out.println("margin-top: 1px;");
        out.println("}");
        out.println(".content-box-header h3 {");
        out.println("float: left;");
        out.println("padding: 6px 15px 10px;");
        out.println("}");
        out.println(".content-box-noheader {");
        out.println("padding: 10px;");
        out.println("}");
        out.println(".content-box {");
        out.println("background: none repeat scroll 0 0 #FFFFFF;");
        out.println("border: 1px solid #CCCCCC;");
        out.println("margin: 0 0 20px;");
        out.println("}");
        out.println(".content-box-content {");
        out.println("border-top: 1px solid #CCCCCC;");
        out.println("font-size: 13px;");
        out.println("padding: 20px;");
        out.println("}");
        out.println(".content-box-newactivity {");
        out.println("padding: 10px;");
        out.println("}");
        out.println(".content-box-newactivity .button {");
        out.println("float: right;");
        out.println("margin-top: 10px;");
        out.println("width: auto;");
        out.println("}");
        out.println(".content-box-newactivity label {");
        out.println("display: block;");
        out.println("float: left;");
        out.println("font-weight: bold;");
        out.println("height: 25px;");
        out.println("line-height: 25px;");
        out.println("margin: -5px 0 5px;");
        out.println("padding: 0 10px 0;");
        out.println("text-shadow: 0 1px 0 #FFFFFF;");
        out.println("text-transform: uppercase;");
        out.println("width: 200px;");
        out.println("}");
        out.println(".content-box textarea {");
        out.println("background-position: 10px 6px;");
        out.println("border: 1px solid #BBBBBB;");
        out.println("box-shadow: 0 2px 2px #CCCCCC inset, 0 1px 0 #FFFFFF;");
        out.println("color: #666666;");
        out.println("display: block;");
        out.println("float: left;");
        out.println("margin: 0 10px;");
        out.println("padding: 10px;");
        out.println("width: 94%;");
        out.println("}");
        out.println(".content-box-header .add{");
        out.println("position:absolute;");
        out.println("right:5px;");
        out.println("top:10px;");
        out.println("width:16px;");
        out.println("height:16px;");
        out.println("}");
        out.println(".column-large-left {");
        out.println("float: left;");
        out.println("width: 65%;");
        out.println("}");
        out.println(".column-small-right {");
        out.println("float: right;");
        out.println("width: 32%;");
        out.println("}");
        out.println(".clear {");
        out.println("clear: both;");
        out.println("}");
        out.println(".full {");
        out.println("width: 100%;");
        out.println("}");
        out.println(".gra {");
        out.println("left: 0;");
        out.println("position: absolute;");
        out.println("}");
        out.println(".gra .normal {");
        out.println("border-radius: 3px 3px 3px 3px;");
        out.println("height: 36px;");
        out.println("width: 36px;");
        out.println("}");
        out.println(".information {");
        out.println("background: url(\""+realPath+"images/information.png\") repeat scroll 0 0 #DBE3FF;");
        out.println("border-color: #A2B4EE;");
        out.println("color: #585B66;");
        out.println("}");
        out.println(".issues {");
        out.println("background-position: 10px 11px !important;");
        out.println("background-repeat: no-repeat !important;");
        out.println("font-size: 13px;");
        out.println("margin: 0;");
        out.println("padding: 0;");
        out.println("position: relative;");
        out.println("width: 99.8%;");
        out.println("}");
        out.println(".issues a {");
        out.println("display: inline-block;");
        out.println("font-style: normal;");
        out.println("line-height: 1.5em;");
        out.println("padding: 5px 10px 5px 36px;");
        out.println("}");
        out.println(".issues span {");
        out.println("display: inline-block;");
        out.println("float: right;");
        out.println("font-style: normal;");
        out.println("line-height: 1.5em;");
        out.println("padding: 5px 10px 5px 36px;");
        out.println("}");
        out.println(".issues  .black{");
        out.println("color: #333333;");
        out.println("padding: 0;");
        out.println("}");
        out.println(".issues .black:hover {");
        out.println("color: #71B300;");
        out.println("}");

        out.println(".issue_item, .user_item, .todo_item {");
        out.println("margin: 2px 0;");
        out.println("padding: 1%;");
        out.println("}");
        out.println(".issue_item:nth-child(2n+1), .user_item:nth-child(2n+1), .tod_item:nth-child(2n+1) {");
        out.println("background: none repeat scroll 0 0 #F6F6F6;");
        out.println("}");
        out.println(".me_message{");
        out.println("margin-bottom:10px;");
        out.println("border-bottom:1px solid #efefef;");
        out.println("height:auto;");
        out.println("overflow:auto;");
        out.println("padding-bottom:5px;");
        out.println("position:relative;");
        out.println("padding-left:45px;");
        out.println("padding-right:30px;");
        out.println("line-height:1.5;");
        out.println("color:#000000;");
        out.println("}");
        out.println(".me_message .pic{");
        out.println("position:absolute;");
        out.println("top:0px;");
        out.println("left:0px;");
        out.println("}");
        out.println(".mtop {");
        out.println("margin-top: 10px;");
        out.println("}");
        out.println(".mleft{");
        out.println("margin-left: 10px;");
        out.println("}");
        out.println(".mright {");
        out.println("margin-right: 10px;");
        out.println("}");
        out.println(".mbuttom {");
        out.println("margin-buttom: 10px;");
        out.println("}");

        out.println("}");
        out.println(".right {");
        out.println("float: right;");
        out.println("}");

        out.println("</style>");
        out.println("</head>\n<body>");
        out.println("	<div id=\"body-wrapper\">");
        out.println("<div id=\"main-content\">");
     // step 1
        Document document = new Document();
        // step 2
        PdfWriter.getInstance(document, new FileOutputStream(pdf));
        // step 3
        document.open();
        // step 4
        String snippet;
            // create the snippet
            snippet = createHtmlSnippet(projectList,realPath);
            // use the snippet for the HTML page
            out.println(snippet);
            // use the snippet for the PDF document
            java.util.List<Element> objects
                = HTMLWorker.parseToList(
                    new StringReader(snippet), styles, providers);
            for (Element element : objects)
                document.add(element);
        // step 5
        document.close();
        // flush and close the HTML stream
        out.println("</div>\n</div>");
        out.print("</body>\n</html>");
        out.flush();
        out.close();
        // close the database connection
    }
 
    /**
     * Sets the styles for the HTML to PDF conversion
     * @param styles a StyleSheet object
     */
    public void setStyles(StyleSheet styles) {
        this.styles = styles;
    }
 
    /**
     * Set some extra properties.
     * @param providers the properties map
     */
    public void setProviders(HashMap<String, Object> providers) {
        this.providers = providers;
    }
 
    /**
     * Creates an HTML snippet with info about a movie.
     * @param movie the movie for which we want to create HTML
     * @return a String with HTML code
     */
    public String createHtmlSnippet(List<Project> projectList,String realPath) {
        StringBuffer buf = new StringBuffer();
        
        for(int i = 0; i < projectList.size(); i++) {
        	Project p = projectList.get(i);
        	if(i%2 == 0) {
        		buf.append("<div class=\"content-box column-left\">");
				buf.append("<div class=\"content-box-noheader\">");
				buf.append("<h4><a href=\"project.jspx?id="+p.getId()+"\">"+p.getName()+"</a></h4>");
				buf.append("<img src=\""+realPath+"report/project"+p.getId()+".jpg\"/>");
				buf.append("</div>\n</div>");
        	} else {
        		buf.append("<div class=\"content-box column-right\">");
				buf.append("<div class=\"content-box-noheader\">");
				buf.append("<h4><a href=\"project.jspx?id="+p.getId()+"\">"+p.getName()+"</a></h4>");
				buf.append("<img src=\""+realPath+"report/project"+p.getId()+".jpg\"/>");
				buf.append("</div>\n</div>");
        	}
        }
        
        return buf.toString();
    }
	
}
